package com.boboPlanet.user.controller;

import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.user.annotation.LimitPass;
import com.boboPlanet.user.entity.dto.ArtTypeDTO;
import com.boboPlanet.user.entity.vo.ArtTypePageVO;
import com.boboPlanet.user.entity.vo.ArtTypeVO;
import com.boboPlanet.user.service.ArticleTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/2/23
 **/
@RestController
@RequestMapping("/articleOperate")
@Api(tags = "文章类型处理",value = "文章类型处理")
public class ArticleTypeController {

    @Resource
    private ArticleTypeService articleTypeService;


    @GetMapping("/getAllArtTypes")
    @ApiOperation("获取正常全部分类")
    @LimitPass
    public ResponseResult<List<ArtTypeVO>> getAllArtTypes(){
        return ResponseResult.isSuccess(articleTypeService.getAllArtTypes());
    }

    @GetMapping("/addArtTypes")
    @ApiOperation("添加分类")
    public ResponseResult<Boolean> addArtTypes(@RequestParam("typeName") String typeName){
        return ResponseResult.isSuccess(articleTypeService.addArtTypes(typeName));
    }

    @GetMapping("/updateArtTypes/{typeId}")
    @ApiOperation("修改分类")
    public ResponseResult<Boolean> updateArtTypes(@RequestParam("typeName") String typeName,@PathVariable("typeId") Long typeId){
        return ResponseResult.isSuccess(articleTypeService.updateArtTypes(typeName,typeId));
    }

    @PostMapping("/getAllArtTypesByPage")
    @ApiOperation("分页查询分类")
    public ResponseResult<ArtTypePageVO> getAllArtTypesByPage(@RequestBody ArtTypeDTO dto){
        return ResponseResult.isSuccess(articleTypeService.getAllArtTypesByPage(dto));
    }

    @PostMapping("/deleteByIds")
    @ApiOperation("批量作废分类")
    public ResponseResult<Boolean> deleteByIds(@RequestBody List<Long> typeIds){
        return ResponseResult.isSuccess(articleTypeService.deleteByIds(typeIds));
    }

    @PostMapping("/resumeTypeByIds")
    @ApiOperation("批量恢复作废分类")
    public ResponseResult<Boolean> resumeTypeByIds(@RequestBody List<Long> typeIds){
        return ResponseResult.isSuccess(articleTypeService.resumeTypeByIds(typeIds));
    }


}
